<?php
if (isset($_POST['get'])) {
	include '../caiji/'.$_POST['aik_col_rule'];
}
if (isset($_POST['save'])) {
	$_data['aik_video_name'] = $_POST['aik_video_name'];
	$_data['aik_video_seo'] = $_POST['aik_video_seo'];
	$_data['aik_video_img'] = $_POST['aik_video_img'];
	$_data['aik_video_group'] = $_POST['aik_video_group'];
	$_data['aik_video_pay'] = $_POST['aik_video_pay'];
	$_data['aik_video_int'] = $_POST['aik_video_int'];
	$hobby_arr = array();
    $hobby_arr = $_POST['usergroup'];
    $_data['aik_video_usergroup'] = implode(',', $hobby_arr);//把数组转换为字符串
	$_data['aik_video_level'] = $_POST['aik_video_level'];
	$_data['aik_video_jiexi'] = $_POST['aik_video_jiexi'];
	$_data['aik_video_url'] = $_POST['aik_video_url'];
	$_data['aik_video_remarks'] = $_POST['aik_video_remarks'];
	$_data['aik_video_zylink'] = $_POST['aik_video_zylink'];
	$_data['aik_video_col'] = $_POST['aik_video_col'];
	if(move_uploaded_file($_FILES['aik_video_img']['tmp_name'],'../../../upload/'.$_FILES['aik_video_img']['name'])){  
	$_data['aik_video_img']='/upload/'.$_FILES['aik_video_img']['name'];}	
	null_back($_data['aik_video_img'], '请输入或上传图片');
	
	$result = mysql_query('select * from aikcms_video where aik_video_zylink = "' . $_POST['aik_video_zylink'] . '"');
	$row=mysql_fetch_array($result);
	if  (($_POST['aik_video_zylink']<>'')&&($row)) {
	$sql = 'update aikcms_video  set ' . arrtoupdate($_data) . ' where id = ' . $row['id'] . '';
	if (mysql_query($sql)) {
		alert_href('视频更新成功!', 'video_list.php');	
	} else {
		alert_back('修改失败!');
	}
	
	}else{
	$str = arrtoinsert($_data);
	$sql = 'insert into aikcms_video (' . $str[0] . ') values (' . $str[1] . ')';
	if (mysql_query($sql)) {
	alert_href('视频发布成功!', 'video_list.php');
	} else {
	alert_back('发布失败!');
	}	
	}		
}

if (isset($_GET['del'])) {
	$sql = 'delete from aikcms_video where id = ' . $_GET['del'] . '';
	if (mysql_query($sql)) {
		alert_href('删除成功!', 'video_list.php');
	} else {
		alert_back('删除失败！');
	}
}